import tornado.ioloop
import tornado.web
from time import time
from operator import itemgetter

i=0
class rout(tornado.web.RequestHandler):
    def get(self):
		count = {}
		words=open("test.txt").read().split()
		for word in words:
			if count.has_key(word):
				count[word] = count[word] + 1
			else:
				count[word] = 1		
		strs=[]
		for key,value in count.items():
			strs.append(key)
			strs.append(':')
			strs.append(str(value))
			strs.append(";")
		global i
		i+=1
		print i
		self.write("".join(strs))

app = tornado.web.Application([
    (r"/", rout),
])

if __name__ == "__main__":
    app.listen(8080)
    tornado.ioloop.IOLoop.instance().start()